package fy.test;

import org.json.JSONException;
import org.json.JSONObject;

import com.seeyon.client.CTPRestClient;
import com.seeyon.client.CTPServiceClientManager;
import java.util.HashMap;
import java.util.Map;

public class Fy_OrgManager {

    public static JSONObject getMember(long memberID) {
        CTPServiceClientManager clientManager = CTPServiceClientManager
                .getInstance("http://10.111.0.54:80");

        // 取得REST动态客户机实例
        CTPRestClient client = clientManager.getRestClient();
        client.authenticate("fy_form_reader", "form_reader2015");
        String result = client.get("orgMember/" + memberID, String.class);
        try {
            return new JSONObject(result);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }

    public static void createDept() {
        CTPServiceClientManager clientManager = CTPServiceClientManager
                .getInstance("http://10.111.0.54:80");

        // 取得REST动态客户机实例
        CTPRestClient client = clientManager.getRestClient();
        client.authenticate("fy_form_reader", "form_reader2015");
        Map<String, Object> map = new HashMap();
        map.put("orgAccountId", -38542217215194594l);
        map.put("name", "信息");
        map.put("enabled", true);
        map.put("sortId", 100);
        map.put("isGroup", false);
        map.put("superior", -38542217215194594l);
        map.put("path", "000000180260");
//        map.put("isGroup", false);

//                 "orgAccountId": 967547186016371000, 【必填】
//    "id": 7313901301646381000, 
//    "name": "炼狱殿", 【必填】
//    "enabled": true, 【必填】
//    "sortId": 2, 【必填】
//    "isGroup": false, 【必填】
//    "superior": 967547186016371000, 【必填】
//    "path": "000000050002", 【必填】
        String result = client.post("orgDepartment", map, String.class);
        System.out.println(result);
    }

    public static void main(String[] args) {
       createDept();
    }
}
